package com.djx.goods.controller;

import com.djx.common.domain.Goods;
import com.djx.common.domain.request.GoodsRequest;
import com.djx.common.domain.response.GoodsResPonse;
import com.djx.common.result.Result;
import com.djx.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Resource
    public GoodsService goodsService;

    /**
     * 商品列表
     * @param goodsRequest
     * @return
     */
    @PostMapping("/list")
    public Result<List<GoodsResPonse>> getList(@RequestBody GoodsRequest goodsRequest){
        List<GoodsResPonse> list=goodsService.getList(goodsRequest);
        return Result.success(list);
    };
    /**
     * 商品回显
     */
    @PostMapping("/find/{id}")
    public Result<Goods> getList(@PathVariable Integer id){
        Goods goods=goodsService.findGoods(id);
        return Result.success(goods);
    };
    /**
     * 商品修改
     */
    @PostMapping("/update")
    public Result updateGoods(@RequestBody Goods goods){
        goodsService.updateGoods(goods);
        return Result.success("修改成功");
    };
    @GetMapping("/chouJiang")
    public Result chouJiang(){
        Result result=goodsService.chouJiang();
        return result;
    }
}
